<!DOCTYPE html>
<html >
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1" />
	<!--响应式布局，宽度等于设备宽度-->
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
	<title>实验云</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/head.css">
	<link rel="stylesheet" type="text/css" href="css/cropper.min.css">
	<link rel="stylesheet" type="text/css" href="css/sitelogo.css">
	<!--<link rel="stylesheet" type="text/css" href="css/croppermain.css">-->
	<style>
		.form-horizontal .form-group{
			margin: 0 0 25px 0;
		}
	</style>
</head>
<body>
	<div class="menu">
		<div class="container con_header">
			<nav class="navbar" role="navigation">
			    <div class="container-fluid">
				    <div class="navbar-header">
				        <button type="button" class="navbar-toggle" data-toggle="collapse"
				                data-target="#cloud-navbar-collapse">
				            <span class="sr-only">切换导航</span>
				            <span class="icon-bar"></span>
				            <span class="icon-bar"></span>
				            <span class="icon-bar"></span>
				        </button>
				        <div style="width: 40px; height: 40px;">
							<a class="navbar-brand" href="index.html">
								<img src="img/logo.png" style="width: 40px; height: 40px;">
							</a>
						</div>
				    </div>
				    <div class="collapse navbar-collapse" id="cloud-navbar-collapse">
				        <ul class="nav navbar-nav">
				            <li class="hov"><a href="courseLibrary.html">课程库</a></li>
				            <li class="hov"><a href="scrachPro.html">Scratch作品展</a></li>
							<li class="hov"><a href="scratch/ide.html">Scratch 3.0 在线编程</a></li>
				            <li class="hov"><a href="personalMain.html">个人总览</a></li>
				            <li class="hov"><a href="myCourse.html">我的课程</a></li>
				            <div class="mobile-show">
				            	<li><a href="personalCenter.html">个人信息</a></li>
	            				<li><a href="javascript:;" onclick="logOut()">退出登录</a></li>
				            </div>
							<li class="dropdown head-box">
								<a href="#" class="head-pic" data-toggle="dropdown">
									<img id="userImg" src="img/head_pic.png">
									<span id="userName"></span>
								</a>
								<ul class="dropdown-menu">
									<li><a href="personalCenter.html">个人信息</a></li>
									<li><a href="javascript:;" onclick="logOut()">退出登录</a></li>
								</ul>
							</li>
				        </ul>
				    </div>
			    </div>
			</nav>
		</div>
	</div>
	<div class="main">
		<div class="container">
			<div class="row">
				<p class="main-tit col-md-2 col-xs-4 text-c">个人信息</p>
			</div>
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">头像</div>
				<div class="col-md-8 col-xs-6">
					<img src="img/head_pic.png" class="touxiang">
				</div>
				<div class="col-md-2 col-xs-3 text-c"><a href="javascript:;" class="change">修改</a></div>
			</div>
			<div class="change-box headimg-box">
				<div class="col-md-8 col-md-offset-2 col-xs-8 col-xs-offset-2">
					<img src="img/head_bg.png" style="width: 150px;height: 150px;" data-toggle="modal" data-target="#avatar-modal">
				</div>
				<div class="modal fade" id="avatar-modal" aria-hidden="true" aria-labelledby="avatar-modal-label" role="dialog" tabindex="-1">
					<div class="modal-dialog modal-lg">
						<div class="modal-content">
							<!--<form class="avatar-form" action="upload-logo.php" enctype="multipart/form-data" method="post">-->
							<form class="avatar-form">
								<div class="modal-header">
									<button class="close" data-dismiss="modal" type="button">&times;</button>
									<h4 class="modal-title" id="avatar-modal-label">上传图片</h4>
								</div>
								<div class="modal-body">
									<div class="avatar-body">
										<div class="avatar-upload">
											<input class="avatar-src" name="avatar_src" type="hidden">
											<input class="avatar-data" name="avatar_data" type="hidden">
											<label for="avatarInput" style="line-height: 35px;">图片上传</label>
											<button class="btn btn-primary"  type="button" style="height: 35px;" onclick="$('input[id=avatarInput]').click();">请选择图片</button>
											<span id="avatar-name"></span>
											<input class="avatar-input hide" id="avatarInput" name="avatar_file" type="file"></div>

											<input hidden id="pro" value="">

										<div class="row">
											<div class="col-md-9">
												<div class="avatar-wrapper"></div>
											</div>
											<div class="col-md-3">
												<div class="avatar-preview preview-lg" id="imageHead"></div>
												<!--<div class="avatar-preview preview-md"></div>
                                        <div class="avatar-preview preview-sm"></div>-->
											</div>
										</div>
										<div class="row avatar-btns">
											<div class="col-md-4">
												<div class="btn-group">
													<button class="btn btn-primary fa fa-undo" data-method="rotate" data-option="-90" type="button" title="Rotate -90 degrees"> 向左旋转</button>
												</div>
												<div class="btn-group">
													<button class="btn  btn-primary fa fa-repeat" data-method="rotate" data-option="90" type="button" title="Rotate 90 degrees"> 向右旋转</button>
												</div>
											</div>
											<div class="col-md-5" style="text-align: right;">

											</div>
											<div class="col-md-3">
												<button class="btn btn-primary btn-block avatar-save fa fa-save" type="button" data-dismiss="modal"> 保存头像</button>
											</div>
										</div>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>

				<div class="loading" aria-label="Loading" role="img" tabindex="-1"></div>

				<div class="col-md-2 prompt">
					注意：<br/>
					1.上传头像大小不要超过100KB<br/>
					2.上传格式为JPG、PNG等
				</div>
			</div>
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">昵称</div>
				<div class="col-md-8 col-xs-6"><span id="loginName">编程云</span></div>
			</div>
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">姓名</div>
				<div class="col-md-8 col-xs-6"><span id="users">编程云</span></div>
				<div class="col-md-2 col-xs-3 text-c"><a href="javascript:;" class="change changeName">修改</a></div>
			</div>
			<div class="change-box">
				<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">
					<input type="text" class="form-control" id="newName" placeholder="请输入姓名"/>
					<button type="button" onclick="changeName()" class="btn btn-block save-btn">保存</button>
				</div>
			</div>
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">性别</div>
				<div class="col-md-8 col-xs-6"><span id="gender">男</span></div>
				<div class="col-md-2 col-xs-3 text-c"><a href="javascript:;" class="change changeSex">修改</a></div>
			</div>
			<div class="change-box">
				<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">
					<div class="radio" id="gender-radio">
						<label>
							<input type="radio" name="gender" id="male"
								   value="0" checked> 男
						</label>
						<label style="margin-left: 40px;">
							<input type="radio" name="gender" id="female"
								   value="1"> 女
						</label>
					</div>
					<button type="button" onclick="changeGender()" class="btn btn-block save-btn">保存</button>
				</div>
			</div>
			<!--<div class="person-inf">-->
				<!--<div class="col-md-2 col-xs-3 text-c person-tit">学分</div>-->
				<!--<div class="col-md-8 col-xs-6"><span>20</span></div>-->
				<!--&lt;!&ndash; <div class="col-md-2 col-xs-3 text-c" class="text-c"><a href="javascript:;" class="change">修改</a></div> &ndash;&gt;-->
			<!--</div>-->
			<!--&lt;!&ndash; <div class="change-box"></div> &ndash;&gt;-->
			<!--<div class="person-inf">-->
				<!--<div class="col-md-2 col-xs-3 text-c person-tit">金币</div>-->
				<!--<div class="col-md-8 col-xs-6"><span>0.0</span></div>-->
				<!--<div class="col-md-2 col-xs-3 text-c" class="text-c"><a href="javascript:;" class="change">充值</a></div>-->
			<!--</div>-->
			<!--<div class="change-box">-->
				<!--<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">-->
					<!--<input type="text" class="form-control" placeholder=""/>-->
					<!--<button type="button" class="btn btn-block save-btn">充值</button>-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="person-inf">-->
				<!--<div class="col-md-2 col-xs-3 text-c person-tit">QQ</div>-->
				<!--<div class="col-md-8 col-xs-6"><span>123456172</span></div>-->
				<!--<div class="col-md-2 col-xs-3 text-c" class="text-c"><a href="javascript:;" class="change">绑定</a></div>-->
			<!--</div>-->
			<!--<div class="change-box">-->
				<!--<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">-->
					<!--<input type="text" class="form-control" placeholder=""/>-->
					<!--<button type="button" class="btn btn-block save-btn">确定</button>-->
				<!--</div>-->
			<!--</div>-->
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">手机号</div>
				<div class="col-md-8 col-xs-6"><span id="phone"></span></div>
				<div class="col-md-2 col-xs-3 text-c"><a href="javascript:;" class="change changePhone">修改</a></div>
			</div>
			<div class="change-box">
				<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">
					<input type="text" id="newPhone" class="form-control" placeholder=""/>
					<button type="button" onclick="changePhone()" class="btn btn-block save-btn">确定</button>
				</div>
			</div>
			<div class="person-inf">
				<div class="col-md-2 col-xs-3 text-c person-tit">密码</div>
				<div class="col-md-8 col-xs-6"><span>********</span></div>
				<div class="col-md-2 col-xs-3 text-c"><a href="javascript:;" class="change changePsd">修改</a></div>
			</div>
			<div class="change-box" style="height: 190px;">
				<div class="col-md-4 col-xs-8 col-md-offset-2  col-xs-offset-2">
					<input type="password" id="oldPwd" class="form-control" placeholder="请输入原密码"/>
					<input type="password" id="newPwd" class="form-control" placeholder="请输入新密码" style="margin-top: 10px;"/>
					<button type="button" onclick="changePwd()" class="btn btn-block save-btn">确认修改</button>
				</div>
			</div>
		</div>
		<div class="container" id="schoolInf">
			<div class="row">
				<p class="main-tit col-md-2 col-xs-4 text-c" style="margin-bottom: 30px;">院校信息</p>
			</div>
			<form class="form-horizontal" role="form">
				<input type="hidden" id="id" typeof="text"/>
				<div class="form-group" style="margin-bottom: 25px;">
					<label class="col-md-2 control-label" for="workId" style="text-align: center;">学号</label>
					<div class="col-md-3">
						<input class="form-control" id="workId" type="text"/>
					</div>
				</div>
				<div class="form-group" style="margin-bottom: 25px;">
					<label class="col-md-2 control-label" for="college" style="text-align: center;">学校</label>
					<div class="col-md-3">
						<select class="form-control" id="college">
							<option value="">--请选择学校--</option>
						</select>
					</div>
					<label class="col-md-2 control-label" for="department">学院/系</label>
					<div class="col-md-3">
						<select class="form-control" id="department">
							<option value="">--请选择学院--</option>
						</select>
					</div>
				</div>
				<div class="form-group" style="margin-bottom: 25px;">
					<label class="col-md-2 control-label" for="major" style="text-align: center;">专业</label>
					<div class="col-md-3">
						<input class="form-control" id="major" type="text"/>
					</div>
				</div>
				<div class="form-group" style="margin-bottom: 25px;">
					<label class="col-md-2 control-label" for="rank" style="text-align: center;">职称</label>
					<div class="col-md-3">
						<select class="form-control" id="rank">
							<option value="">--请选择教师职称--</option>
						</select>
					</div>
				</div>
				<div class="form-group" style="margin-bottom: 25px;">
					<label class="col-md-2 control-label" for="desc"  style="text-align: center;">个人简介</label>
					<div class="col-md-5">
						<textarea class="form-control" id="desc" rows="6"></textarea>
					</div>
				</div>
				<div class="form-group">
					<div class="col-md-3 col-md-offset-2">
						<button type="button" class="btn btn-block save-btn" id="submit" style="width: 100%">保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="footer">
		<div class="container">
			<ul>
				<li class="footer-tit">联系与反馈</li>
				<li><a href="#">联系我们</a></li>
				<li><a href="#">意见反馈</a></li>
			</ul>
			<ul>
				<li class="footer-tit">资源共享</li>
				<li><a href="#">学校支持</a></li>
				<li><a href="#">文章干货</a></li>
				<li><a href="#">相关下载</a></li>
			</ul>
			<ul>
				<li class="footer-tit">关注我们</li>
				<li><a href="#">微信公众号</a></li>
				<li><a href="#">QQ群</a></li>
			</ul>
		</div>
	</div>

    <script type="text/javascript" src="js/jquery-1.10.0.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/HOST.js"></script>
	<script type="text/javascript" src="js/main.js"></script>
    <!--<script type="text/javascript" src="js/cropper.min.js"></script>-->
    <!--<script type="text/javascript" src="js/croppermain.js"></script>-->
	<script type="text/javascript" src="js/cropper.js"></script>
	<script type="text/javascript" src="js/sitelogo.js"></script>
	<script type="text/javascript" src="js/html2canvas.min.js"></script>
	<script type="text/javascript" src="js/jquery.form.min.js"></script>
	<script type="text/javascript" src="layer/layer.js"></script>
	<script src="js/upload/jquery.ui.widget.js"></script>
	<script src="js/upload/jquery.iframe-transport.js"></script>
	<script type="text/javascript" src="js/upload/jquery.fileupload.js"></script>
	<script>
		$(document).ready(function () {
			var userMain = JSON.parse(getCookie('loginResult'));

			if(userMain == "" || userMain == null){
				window.location.href = "index.html";
			}

			if(window.location.href.indexOf("users") > -1){
				$(".changeName").eq(0).click();
			}

            getCollegeList();
            getCollegeInfo(userMain.id,userMain.identityRole);

            if (userMain.identityRole == "0") {
                $("label[for='rank']").parent().addClass("hidden");
                $("label[for='desc']").parent().addClass("hidden");

            } else if (userMain.identityRole == "1") {
                $("label[for='workId']").text("教工号");
                getTeacherTitle();
            }

			if(userMain.photo != "" && userMain.photo != null){
				$("#userImg").attr("src",userMain.photo);
				$(".touxiang").attr("src",userMain.photo);
			}
			$("#userName").text(userMain.loginName);
			$("#loginName").text(userMain.loginName);
			$("#users").text(userMain.name?userMain.name:"");
			$("#phone").text(userMain.phone);
			if (userMain.gender == "0") {
			    $("#gender").text("男");
			} else {
                $("#gender").text("女");
			}
			var token = userMain.token;
			$('#avatarInput').attr("data-url", '/servlet/fileUploadServlet?token=' + token);
			$('#avatarInput').fileupload({
				dataType: 'json',
				done: function (e, data) {
					if (data.result.code == 0) {
						console.log(data);
						console.log(data.result);
//                layer.close(index);
						$("#pro").val(data.result.value[0].url);
					}
				}
			});
			$(".avatar-save").on("click", function() {
				var data = {
					user: {
						token: token,
						photo: $('#pro').val()
					}
				};
				request('system.user.updateUserInfo', data, function callback(result) {
					console.log(JSON.stringify(result));
					if (result.code == 0) {
//						console.log("ok");
//						$(".uploadBox").eq(0).css("display", "none");
						var loginResult = JSON.stringify(result.value);
						setCookie('loginResult',loginResult,24*60*60*1000);
						window.location.reload();
					}
				});
			});

			$('#submit').on('click',function () {
			    onsubmit();
			});
		});

		//获取学校列表
		function getCollegeList() {
		    var data = {};
            request('system.organization.getCollegeSelect', data, function callback(result) {
//                console.log(JSON.stringify(result));
                if (result.code == 0) {
                    for (var i= 0;i < result.value.length;i++) {
                        $('#college').append("<option value='"+result.value[i].id+"'>"+result.value[i].name+"</option>");
                    }
                }
                $('#college').change(function() {
                    $("#department > option:gt(0)").each(function(){//避免option累加
                        $("#department").empty();
                        $('#department').append("<option value=''>"+"--请选择学院--"+"</option>");
                    });
                    var datas = {
                        organization:{
                            id : $('#college option:selected').val()
						}
					};
                    request('system.organization.getDepartmentSelect', datas, function callback(result) {
                        if (result.code == 0) {
                            for (var i= 0;i < result.value.length;i++) {
                                $('#department').append("<option value='"+result.value[i].id+"'>"+result.value[i].name+"</option>");
                            }
                        }
					});
                });
            });

		}

		//获取教师职称列表
		function getTeacherTitle() {
            var data={
                dict:{
                    type:'teacher_title'
                }
            };
            request('system.dict.get', data, function callback(result) {
//                console.log(JSON.stringify(result));
                if (result.code == 0) {
                    for (var i= 0;i < result.value.length;i++) {
                        if ($('#rank').attr('select-data') == result.value[i].id) {
                            $('#rank').append("<option value='"+result.value[i].id+"' selected>"+result.value[i].label+"</option>");
						} else {
                            $('#rank').append("<option value='"+result.value[i].id+"'>"+result.value[i].label+"</option>");
						}
					}
                }
            });
		}

		//获取用户相关院校信息
		function getCollegeInfo(id,identityRole) {
		    var data = {
		        user:{
		            id : id,
                    identityRole : identityRole
				}
			};

            request('system.user.getCollegeInfo', data, function callback(result) {
//                console.log(JSON.stringify(result));
                if (result.code == 0) {
                    $('#id').val(result.value.id);
                    $('#workId').val(result.value.workId);
                    $('#major').val(result.value.major);
                    $('#college').find("option[value='"+ result.value.collegeId + "']").attr('selected',true);
                    var datas = {
                        organization:{
                            id : $('#college option:selected').val()
                        }
                    };
                    var dd = result.value.departmentId;
                    request('system.organization.getDepartmentSelect', datas, function callback(result) {
                        if (result.code == 0) {
                            for (var i= 0;i < result.value.length;i++) {
                                if (dd == result.value[i].id){
                                    $('#department').append("<option value='"+result.value[i].id+"' selected>"+result.value[i].name+"</option>");
								} else {
                                    $('#department').append("<option value='"+result.value[i].id+"'>"+result.value[i].name+"</option>");
								}

                            }
                        }
                    });
                    if (identityRole == "1") {
                        $('#desc').val(result.value.desc);
                        $('#rank').attr("select-data",result.value.rankId);
					}
                } else {
                    layer.msg(result.msg, {time: 2000, icon:5});
				}
            });
		}

		//提交表单
		function onsubmit() {
		    var identityRole = JSON.parse(getCookie('loginResult')).identityRole;
		    var userId = JSON.parse(getCookie('loginResult')).id;
		    var workId = $('#workId').val();
		    var collegeId = $('#college').val();
		    var departmentId = $('#department').val();
		    var major = $('#major').val();
		    var id = $('#id').val();
		    if (workId == null || workId.trim() == "") {
		        layer.msg("学号不能为空",{time: 2000, icon:5});
		        return ;
			}
			if (!/^[0-9]\d{4,15}$/.test(workId)) {
                layer.msg("学号格式不正确",{time: 2000, icon:5});
                return ;
			}
            if (collegeId == null || collegeId.trim() == "") {
                layer.msg("学校不能为空",{time: 2000, icon:5});
                return ;
            }
            if (departmentId == null || departmentId.trim() == "") {
                layer.msg("学院不能为空",{time: 2000, icon:5});
                return ;
            }
            if (major == null || major.trim() == "") {
                layer.msg("专业不能为空",{time: 2000, icon:5});
                return ;
            }
		    if (identityRole == '1') {
		        var desc = $('#desc').val();
		        var rank = $('#rank').val();
                if (rank == null || rank.trim() == "") {
                    layer.msg("职称不能为空",{time: 2000, icon:5});
                    return ;
                }
                if (desc == null || desc.trim() == "") {
                    layer.msg("个人描述不能为空",{time: 2000, icon:5});
                    return ;
                }
				var data = {
                    busTeacherInfo : {
                        id : id == "" ? null : id,
                        userId : userId,
                        workId : workId,
                        collegeId : collegeId,
                        departmentId : departmentId,
                        major : major,
                        desc : desc,
                        rankId : rank
                    }
				};
                request('business.busTeacherInfo.insertOrUpdateTeacher', data, function callback(result) {
                    if (result.code == 0) {
                        layer.msg("保存成功",{time: 2000, icon:1});
                    }else {
                        layer.msg("保存失败",{time: 2000, icon:5});
                    }
                });
			} else {
				if(!JSON.parse(getCookie('loginResult')).name){
					layer.msg("请先完善姓名",{time: 2000, icon:5});
					window.location.href = "#users";
					$(".changeName").eq(0).trigger("click");
					return false;
				}
                var data = {
                    busStudentInfo : {
                        id : id == "" ? null : id,
                        userId : userId,
                        workId : workId,
                        collegeId : collegeId,
                        departmentId : departmentId,
                        major : major
                    }
                };
                request('business.busStudentInfo.insertOrUpdateStu', data, function callback(result) {
                    if (result.code == 0) {
                        layer.msg(result.msg,{time: 2000, icon:1});
					}else {
                        layer.msg(result.msg,{time: 2000, icon:5});
					}

                });
			}
		}

		function changePhone(){
//			alert(JSON.parse(getCookie('loginResult')).token)
			var newPhone = $("#newPhone").val();
			if(newPhone == null || newPhone.replace(/(^\s*)|(\s*$)/g, "").length ==0 || !/^1[3|5|8|7][0-9]\d{4,8}$/.test(newPhone)){
                layer.msg("手机号输入不正确,请重新输入", {time: 2000, icon:5});
                return
			}
			var data={
				user:{
					token:JSON.parse(getCookie('loginResult')).token,
					phone:newPhone
				}
			};
			change(data);
			$("#phone").text(newPhone);
			$("#newPhone").val("");
			$(".change-box").css("display","none");
			$(".changePhone").attr("ochange",1).text("修改");


//			window.location.reload();
		}
		function changePwd(){
            var oldPwd=$("#oldPwd").val();
            if ( oldPwd == null || oldPwd.replace(/(^\s*)|(\s*$)/g, "").length ==0) {
                //alert(1);
                layer.msg("旧密码不能为空", {time: 2000, icon:5});
                return
            }
		    var newPwd = $("#newPwd").val();
		    if(newPwd == null || newPwd.replace(/(^\s*)|(\s*$)/g, "").length ==0 || !/^([\w\.\_]|[\u4e00-\u9fa5]){6,15}$/.test(newPwd)){
                layer.msg("新密码请输入6~15位，支持中文、字母、数字、下划线和小数点", {time: 2000, icon:5});
                return
			}
			var data={
		        passOld:oldPwd,
                passNew:newPwd,
				user:{
					token:JSON.parse(getCookie('loginResult')).token
				}
			};
            request('system.user.passwordCheckAndChange',data,function callback(result) {
                if (result.code == "0"){
					$("#oldPwd").val("");
					$("#newPwd").val("");
					$(".change-box").css("display","none");
					$(".changePsd").attr("ochange",1).text("修改");
					layer.msg("修改成功", {shade:false,time: 1000, icon:1});
				} else {
                    layer.msg(result.msg, {shade:false,time: 1000, icon:5});
				}
            });

		}
		function changeName(){
		    var newName = $("#newName").val();
		    if ( newName == null || newName.replace(/(^\s*)|(\s*$)/g, "").length ==0) {
                //alert(1);
		        layer.msg("姓名不能为空", {time: 2000, icon:5});
                return
			}
			var data={
				user:{
					token:JSON.parse(getCookie('loginResult')).token,
					name:newName
				}
			};
			change(data);
			$("#users").text(newName);
			$("#newName").val("");
			$(".change-box").css("display","none");
			$(".changeName").attr("ochange",1).text("修改");
		}
		function changeGender(){
		    var checked = $('#gender-radio input:radio:checked').val();
            var data={
                user:{
                    token:JSON.parse(getCookie('loginResult')).token,
                    gender:checked
                }
            };
            change(data);
			if(checked == "0"){
				$("#gender").text("男");
			}else{
				$("#gender").text("女");
			}
			$(".change-box").css("display","none");
			$(".changeSex").attr("ochange",1).text("修改");
		}

//		function changePic(){
//			var data={
//				user:{
//					token:JSON.parse(getCookie('loginResult')).token,
//					phone:detail
//
//				}
//			};
//			change(data);
//		}
//		function changeQQ(){
//			var data={
//				user:{
//					token:JSON.parse(getCookie('loginResult')).token,
//					phone:detail
//
//				}
//			};
//			change(data);
//		}

//		var tokens = JSON.parse(getCookie('loginResult')).token;
//		 //alert(tokens);
//		var datass={
//			user:{
//				token:tokens
//			}
//		};
//$.ajax({
//	url:'http://127.0.0.1:8080QiNiuController.getUptoken.hsr',
//	type: 'GET',
//	data: "Data"+"="+JSON.stringify(datass),
//	dataType: "json",
//	headers:{
//		token:tokens
//	},
//	success: function(result){
//		//alert(1)
////		alert(result.value.token);
////		alert(result.value.domain);
//		//此token为七牛云上传凭证，不要和用户的token弄混了
//		$('#token').val(result.value.token);
//		//domain为七牛云域名，上传的文件的url为域名加文件key
//		$('#domain').val(result.value.domain);
//		//alert(result.value.current)
////		var pages=result.value.pages;
////		var current=result.value.current;
//
//	},
//	error:function(xhr){
//		alert("错误提示： " + xhr.status + " " + xhr.statusText);
//	}
//});
//		function  uploadpic() {
//
//
//			var options  = {
//				url:"http://upload.qiniu.com/",   //同action
//				type:'post',
//				beforeSend:function(xhr){//请求之前
//					alert("开始上传");
////					//设置界面黑掉
//				},
//				success:function(data)
//				{
//					//此处返回文件hash和key
//					var domain = $('#domain').val();
//
//				console.log("上传成功！图片地址为："+domain+"/"+data.key+JSON.stringify(data));
//
//				},
//
//				complete:function(xhr){//请求完成
//					alert("请求完成！");
//
//				},
//				error: function(xhr,status,msg){
//
//					alert("状态码"+status+"; "+msg)
//
//				}
//			};
//			$("#avatar_pic").ajaxSubmit(options);
//		}

	</script>
	<script type="text/javascript">
		//做个下简易的验证  大小 格式
		$('#avatarInput').on('change', function(e) {
			var filemaxsize = 1024 * 5;//5M
			var target = $(e.target);
			var Size = target[0].files[0].size / 1024;
			if(Size > filemaxsize) {
				alert('图片过大，请重新选择!');
				$(".avatar-wrapper").children().remove;
				return false;
			}
			if(!this.files[0].type.match(/image.*/)) {
				alert('请选择正确的图片!')
			} else {
				var filename = document.querySelector("#avatar-name");
				var texts = document.querySelector("#avatarInput").value;
				var teststr = texts; //你这里的路径写错了
				testend = teststr.match(/[^\\]+\.[^\(]+/i); //直接完整文件名的
				filename.innerHTML = testend;
			}

		});


//		$(".avatar-save").on("click", function() {
//			var img_lg = document.getElementById('imageHead');
//			// 截图小的显示框内的内容
//			html2canvas(img_lg, {
//				allowTaint: true,
//				taintTest: false,
//				onrendered: function(canvas) {
//					canvas.id = "mycanvas";
//					//生成base64图片数据
//					var dataUrl = canvas.toDataURL("image/jpeg");
//					var newImg = document.createElement("img");
//					newImg.src = dataUrl;
//					imagesAjax(dataUrl)
//				}
//			});
//		});

		function imagesAjax(src) {
			console.log(src);
			//将src传给后台
		}
	</script>
</body>
</html>